import Vue from "vue";
import VueRouter from "vue-router";
// import Login from "../views/default/login.vue";
const requireAll = (context) => context.keys().map(context);
const c = require.context(
  `../views/${process.env.VUE_APP_FOLDER_NAME || "default"}/`,
  false,
  /\.vue$/
);
const componments = requireAll(c).map((item) => {
  return item.default;
});
const LoginComponment = componments[0];
const SwitchSiteComponment = componments[1];

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "login",
    // component: Login,
    component: LoginComponment,
  },
  {
    path: "/switchSite",
    name: "switchSite",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: SwitchSiteComponment,
  },
];

const router = new VueRouter({
  base: process.env.VUE_APP_BASEURL || "/login/",
  routes,
});

export default router;
